 package handling.world.party;

 import client.MapleCharacter;
import server.MapleStatEffect;

import java.io.Serializable;
import java.util.*;










 public class MapleParty implements Serializable {
   private static final long serialVersionUID = 9179541993413738569L;
/*  15 */   private final List<MaplePartyCharacter> members = new LinkedList<>();
   private MaplePartyCharacter leader;
/*  17 */   private int expeditionLink = -1; private int partyId;
   private boolean disbanded = false;
/*  19 */   private String name = "";
   private boolean hidden = false;
/*  21 */   private Map<Integer, Map<Integer, List<Integer>>> partybuffs = new HashMap<>();


   public MapleParty() {}

   public MapleParty(int partyId, MaplePartyCharacter chrfor, String partyName, boolean isHidden) {
/*  27 */     this.leader = chrfor;
/*  28 */     this.members.add(this.leader);
/*  29 */     this.partyId = partyId;
/*  30 */     this.name = partyName;
/*  31 */     this.hidden = isHidden;
   }

   public MapleParty(int partyId, MaplePartyCharacter chrfor, int expeditionLink) {
/*  35 */     this.leader = chrfor;
/*  36 */     this.members.add(this.leader);
/*  37 */     this.partyId = partyId;
/*  38 */     this.expeditionLink = expeditionLink;
/*  39 */     this.name = "";
/*  40 */     this.hidden = false;
   }




   public boolean containsMembers(MaplePartyCharacter member) {
/*  47 */     return this.members.contains(member);
   }




   public void addMember(MaplePartyCharacter member) {
/*  54 */     this.members.add(member);
   }




   public void removeMember(MaplePartyCharacter member) {
/*  61 */     this.members.remove(member);
   }




   public void updateMember(MaplePartyCharacter member) {
/*  68 */     for (int i = 0; i < this.members.size(); i++) {
/*  69 */       MaplePartyCharacter chr = this.members.get(i);
/*  70 */       if (chr.equals(member)) {
/*  71 */         this.members.set(i, member);
       }
     }
   }




   public MaplePartyCharacter getMemberById(int chrId) {
/*  80 */     for (MaplePartyCharacter chr : this.members) {
/*  81 */       if (chr.getId() == chrId) {
/*  82 */         return chr;
       }
     }
/*  85 */     return null;
   }




   public MaplePartyCharacter getMemberByIndex(int index) {
/*  92 */     return this.members.get(index);
   }




   public Collection<MaplePartyCharacter> getMembers() {
/*  99 */     return new LinkedList<>(this.members);
   }




   public int getPartyId() {
/* 106 */     return this.partyId;
   }




   public void setPartyId(int id) {
/* 113 */     this.partyId = id;
   }




   public MaplePartyCharacter getLeader() {
/* 120 */     return this.leader;
   }




   public void setLeader(MaplePartyCharacter nLeader) {
/* 127 */     this.leader = nLeader;
   }




   public int getExpeditionId() {
/* 134 */     return this.expeditionLink;
   }


   public int hashCode() {
/* 139 */     int prime = 31;
/* 140 */     int result = 1;
/* 141 */     result = prime * result + this.partyId;
/* 142 */     return result;
   }


   public boolean equals(Object obj) {
/* 147 */     if (this == obj) {
/* 148 */       return true;
     }
/* 150 */     if (obj == null) {
/* 151 */       return false;
     }
/* 153 */     if (getClass() != obj.getClass()) {
/* 154 */       return false;
     }
/* 156 */     MapleParty other = (MapleParty)obj;
/* 157 */     return (this.partyId == other.partyId);
   }




   public boolean isDisbanded() {
/* 164 */     return this.disbanded;
   }




   public void disband() {
/* 171 */     this.disbanded = true;
   }




   public String getName() {
/* 178 */     return this.name;
   }

   public void setName(String name) {
/* 182 */     this.name = name;
   }




   public boolean isHidden() {
/* 189 */     return this.hidden;
   }

   public void setHidden(boolean hidden) {
/* 193 */     this.hidden = hidden;
   }

   public int getAverageLevel() {
/* 197 */     int n2 = 0;
/* 198 */     for (MaplePartyCharacter d2 : this.members) {
/* 199 */       n2 += d2.getLevel();
     }
/* 201 */     return n2 / this.members.size();
   }

   public void givePartyBuff(int n2, int n3, int n4) {
    if (partybuffs.containsKey(n2)) {
        if (partybuffs.get(n2).containsKey(n3)) {
            if (!partybuffs.get(n2).keySet().isEmpty()) {
                for (Integer integer : partybuffs.get(n2).keySet()) {
                    if (partybuffs.get(n2).get(integer).contains(n4)) {
                        partybuffs.get(n2).get(integer).remove(partybuffs.get(n2).get(integer).indexOf(n4));
                    }
                    if (partybuffs.get(n2).get(integer).isEmpty()) {
                        partybuffs.get(n2).remove(integer);
                    }
                }
            }
            if (!(partybuffs == null || partybuffs.get(n2).isEmpty() || partybuffs.get(n2).get(n3).isEmpty() || partybuffs.get(n2).get(n3).contains(n4))) {
                partybuffs.get(n2).get(n3).add(n4);
            }
        } else {
            ArrayList<Integer> integers = new ArrayList<>();
            integers.add(n4);
            partybuffs.get(n2).put(n3, integers);
        }
    } else {
        HashMap<Integer, List<Integer>> listHashMap = new HashMap<>();
        ArrayList<Integer> integers = new ArrayList<>();
        integers.add(n4);
        listHashMap.put(n3, integers);
        partybuffs.put(n2, listHashMap);
    }
   }

   public int getPartyBuffs(int n2) {
/* 235 */     ArrayList<Integer> arrayList = new ArrayList<>();
/* 236 */     for (Map<Integer, List<Integer>> integerListMap : this.partybuffs.values()) {
/* 237 */       if (integerListMap.containsKey(Integer.valueOf(n2))) {
/* 238 */         for (List<Integer> integers : integerListMap.values()) {
/* 239 */           for (Integer integer : integers) {
/* 240 */             if (!arrayList.contains(integer)) {
/* 241 */               arrayList.add(integer);
             }
           }
         }
       }
     }
/* 247 */     return arrayList.size();
   }

   public int cancelPartyBuff(int n2, int n3) {
    if (partybuffs.containsKey(n2)) {
        if (partybuffs.get(n2).isEmpty()) {
            partybuffs.remove(n2);
        } else {
            for (Integer n4 : (partybuffs.get(n2)).keySet()) {
                if (partybuffs.get(n2).get(n4).isEmpty()) {
                    partybuffs.get(n2).remove(n4);
                    continue;
                }
                if (partybuffs.get(n2).get(n4).contains(n3)) {
                    partybuffs.get(n2).get(n4).remove(partybuffs.get(n2).get(n4).indexOf(n3));
                    return n4;
                }
            }
        }
    }
    return -1;
   }

   public void cancelAllPartyBuffsByChr(int n2) {
    if (partybuffs.isEmpty()) {
        return;
    }
    try {
        for (Integer n3 : partybuffs.keySet()) {
            if (partybuffs.get(n3).isEmpty()) {
                partybuffs.remove(n3);
                continue;
            }
            for (Integer n4 : partybuffs.get(n3).keySet()) {
                MapleCharacter p2;
                if (partybuffs.get(n3).get(n4).isEmpty() || n4 == n2) {
                    partybuffs.get(n3).remove(n4);
                    p2 = MapleCharacter.getOnlineCharacterById(n4);
                    if (n4 == n2 && p2 != null) {
                        MapleStatEffect.apply祈祷众生(p2);
                    }
                    continue;
                }
                if (partybuffs.get(n3).get(n4).contains(n2)) {
                    partybuffs.get(n3).get(n4).remove(partybuffs.get(n3).get(n4).indexOf(n2));
                    p2 = MapleCharacter.getOnlineCharacterById(n4);
                    if (p2 != null) {
                        MapleStatEffect.apply祈祷众生(p2);
                    }
                }
            }
        }
    } catch (Exception exception) {
        // empty catch block
    }
   }
 }


/* Location:              C:\PGX\Server.jar!\handling\world\party\MapleParty.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */